100 REM **********************************************************************
110 REM FILE NAME  - MEMTEST.BAS
120 REM
130 REM WRITTEN BY - GARY PEEK
140 REM              3201 HIGHGATE
150 REM              ST. CHARLES, MO.  63301
160 REM              314 946-5272
170 REM
180 REM LAST UPDATE - 11/17/88
190 REM
200 REM DESCRIPTION - A SIMPLE MEMORY TEST
210 REM
220 REM PLEASE NOTE - PERMISSION IS GRANTED TO COPY THIS PROGRAM ONLY IF
230 REM               COPIED IN ITS ENTIRETY INCLUDING THIS HEADING.
240 REM
250 REM **********************************************************************
260 CLS
270 PRINT "MEMORY TEST-"
280 PRINT "ALTERNATELY WRITES 55 HEX AND AA HEX"
290 PRINT "TO MEMORY LOCATIONS AND REPORTS ERRORS."
300 PRINT:PRINT "HIT ESCAPE TO EXIT OR ANY OTHER KEY TO SELECT MEMORY":PRINT
310 IN$=INKEY$:IF IN$="" THEN 310
320 IF IN$=CHR$(27) THEN END
330 LINE INPUT "ENTER SEGMENT: ";SEGMENT$
340 HEXVAL$=SEGMENT$:HEXLNG=4
350 GOSUB 770
360 IF HEXERROR GOTO 330
370 SEGMENT=DECVAL
380 LINE INPUT "ENTER STARTING OFFSET: ";FIRST$
390 HEXVAL$=FIRST$:HEXLNG=4
400 GOSUB 770
410 IF HEXERROR GOTO 380
420 FIRST=DECVAL
430 LINE INPUT "ENTER ENDING OFFSET: ",LAST$
440 HEXVAL$=LAST$:HEXLNG=4
450 GOSUB 770
460 IF HEXERROR GOTO 430
470 LAST=DECVAL
480 PRINT:PRINT "TEST SEGMENT ";HEX$(SEGMENT);" FROM LOCATIONS ";HEX$(FIRST);" TO ";HEX$(LAST)
490 PRINT "HIT ENTER TO BEGIN OR ANY OTHER KEY TO ENTER AGAIN"
500 IN$=INKEY$:IF IN$="" THEN 500
510 IF IN$=CHR$(13) THEN 530 ELSE 260
520 REM ------------------------------------------
530 CLS
540 DEF SEG=SEGMENT
550 FOR MEM=FIRST TO LAST
560  PRINT:PRINT "TESTING ";HEX$(MEM);" - ";
570  A=&H55
580  POKE MEM,A
590  B=PEEK(MEM)
600  IF A=B THEN 620
610  PRINT HEX$(A);" WRITTEN, ";HEX$(B);" READ - ";
620  A=&HAA
630  POKE MEM,A
640  B=PEEK(MEM)
650  IF A=B THEN 670
660  PRINT HEX$(A);" WRITTEN, ";HEX$(B);" READ - ";
670 IN$=INKEY$:IF IN$<>"" THEN 260
680 NEXT MEM
690 DEF SEG
700 GOTO 530
710 REM ---------------------------------------------------------------
720 REM --------------- CALCULATE DECVAL FROM HEXVAL$ -----------------
730 REM -------- ENTER WITH HEXLNG, HEXVAL$ - EXIT WITH DECVAL --------
740 REM ------ EXIT WITH HEXERROR TRUE IF ILLEGAL CHARS. FOUND --------
750 REM ------ EXIT WITH HEXERROR TRUE IF # HEX CHARS. > HEXLNG -------
760 REM ---------------------------------------------------------------
770 HEXLEN=LEN(HEXVAL$)
780 HEXERROR=0:DECVAL=0:HEXMUL=1
790 IF HEXLEN>HEXLNG THEN 850
800 IF HEXVAL$="" THEN 850
810 FOR HEXLOOP=HEXLEN TO 1 STEP-1
820  HEXMID$=MID$(HEXVAL$,HEXLOOP,1)
830  IF ASC(HEXMID$)>=65 AND ASC(HEXMID$)<=70 THEN 860
840  IF ASC(HEXMID$)>=48 AND ASC(HEXMID$)<=57 THEN 860
850  DECVAL=0:HEXERROR=-1:GOTO 890
860  DECVAL=DECVAL+VAL("&H"+HEXMID$)*HEXMUL
870  HEXMUL=HEXMUL*16
880 NEXT HEXLOOP
890 RETURN
